tests/admin-test: Fix --allow-downgrade check
authorJonathan Lebon <jonathan@jlebon.com>
Wed, 20 May 2020 16:37:44 +0000 (12:37 -0400)
committerJonathan Lebon <jonathan@jlebon.com>
Fri, 22 May 2020 17:59:36 +0000 (13:59 -0400)
commit6730acc3504fdc663b8d01a72427d8be695a3adb
tree80127f5e651c7a85710202a193a2758787744687
parent0c8701b89646b057b6e6445fa726323cb0888aa0
tests/admin-test: Fix --allow-downgrade check

We were doing a check to verify that `ostree admin upgrade` wouldn't
accept a downgrade without `--allow-downgrade`. However, there's no
guarantee that the commit it's upgrading from is older than HEAD^ (what
we're upgrading to). Specifically, if the test runs fast enough, the
timestamps could be equal, since the lowest resolution is seconds.

Rework the test so that we first upgrade to HEAD, which we're sure is at
least 1 second apart from HEAD^, and *then* check that downgrade
protection is enforced.

We also can't use `rev-parse testos/buildmaster/x86_64-runtime` as a way
to know what commit the host is sitting on since the ref might've gone
ahead. Instead, just use `ostree admin status | head -n1`. (I played
with using the `ostree/I/J/K` refs, but those depend on what the
boot/subbootversion is and can easily change if we change previous
tests).
tests/admin-test.sh